import axios from 'axios'

 

const isNewVersion = () => {
    let url = `https://jtmc.oss-cn-hangzhou.aliyuncs.com/WH5Version/version.json?t=${new Date().getTime()}`
    axios.get(url).then(res => {
      console.log(res);
      console.log(res.data);
      console.log(res.data.version);
      
      if (res.status === 200) {
        console.log(res.data.version);
        
        let vueVersion = res.data.version || '1.0.0'

        let localVueVersion = localStorage.getItem('vueVersion')

        localStorage.setItem('vueVersion', vueVersion)

        if (localVueVersion && localVueVersion != vueVersion) {

          alert('检测到新版本，请点击确认刷新页面!')

          window.location.reload(true)

          return

        }

      }

    })

}

 

export default {

  isNewVersion

}